#include <REGX52.H>

unsigned char Receve_dat;
void UART_Init()
{

	SCON =0x50; //0101 0000
	PCON = 0x00;
	TMOD = 0x20;		//设置定时器模式
	TL1 = 0xFD;		//设定定时初值
	TH1 = 0xFD;		//设定定时器重装值
	TR1 = 1;		//启动定时器1
	EA=1;
	ES=1;
}


void UART_SendByte(unsigned char Byte)
{
	SBUF=Byte;
	while(TI==0);
	TI=0;
}

 
	
void main()
{
	unsigned char count=0;
	UART_Init();
	while(1)
	{
		 if(P3_5==0)
		 {
			 while(P3_5==0);
			 P1_1=~P1_1;
			 UART_SendByte(0x01);
		 }
			
		}
	}
void UART_Routine() interrupt 4
{
	if(RI==1)					//如果接收标志位为1，接收到了数据
	{
		P2=~SBUF;				//读取数据，取反后输出到LED
		P1_1=~P1_1;
		RI=0;					//接收标志位清0
	}
}